﻿<!--_meta 作为公共模版分离出去-->
<?php 
require_once 'comm/_meta.php';
require_once 'comm/chkLoginState.php';
?>
<!--/meta 作为公共模版分离出去-->

<title>实训中心考勤OA</title>
<meta name="keywords" content="实训中心考勤OA">
<meta name="description" content="实训中心考勤OA">
</head>
<body>
<!--_header 作为公共模版分离出去-->
<?php require_once 'comm/_header.php';
	require_once 'comm/_menu.php';
	$info = new DB();
	
	$res = $info->query('select * from leave_info where stu_id = '.$_SESSION['login_uid']);
	
	//('leave_info',' where stu_id = ');
	
?>
<section class="Hui-article-box">
	<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 
		首页 <span class="c-gray en">&gt;</span> 
		考勤管理 <span class="c-gray en">&gt;</span> 
		请假列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
	<div class="Hui-article">
		<article class="cl pd-20">
			<div class="text-c"> 日期范围：
				<input type="text" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'logmax\')||\'%y-%M-%d\'}'})" id="logmin" class="input-text Wdate" style="width:120px;">
				-
				<input type="text" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'logmin\')}',maxDate:'%y-%M-%d'})" id="logmax" class="input-text Wdate" style="width:120px;">
				
				<button name="" id="" class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
			</div>
			<div class="cl pd-5 bg-1 bk-gray mt-20"> 
			<span class="l">
				<a class="btn btn-primary radius" onclick="leave_add('请假申请单','leave_add.php')" href="javascript:;">
				<i class="Hui-iconfont">&#xe600;</i> 填写请假单</a>
				</span> <span class="r">共有数据：<strong><?php echo count($res);?></strong> 条</span> </div>
			<div class="mt-20">
				<table class="table table-border table-bordered table-bg table-hover table-sort">
					<thead>
						<tr class="text-c">
							<th width="20">ID</th>
							<th width="60">申请日期</th>
							<th width="60">开始时间</th>
							<th width="60">结束时间</th>
							<th width="30">申请天数</th>
							<th width="30">请假类型</th>
							<th width="150">审核进度</th>
							<th width="30">完成状态</th>
							<th width="30">操作</th>
						</tr>
					</thead>
					<tbody>
					<?php foreach ($res as $k=>$v){ 
						$sr=0;
						if ($v['ass_check']){$sr = 20;}
						if ($v['man_check']){$sr = 40;}
						if ($v['lead_check']){$sr = 60;}
						if ($v['cou_check']){$sr = 80;}
						if ($v['admin_check'] && $v['leave_state']==1){$sr = 100;}
					?>
						<tr class="text-c">
							<td><?php echo $v['leave_id'];?></td>
							<td class="text-c"><?php echo $v['create_time'];?></td>
							<td class="text-c"><?php echo $v['leave_starttime'];?></td>
							<td class="text-c"><?php echo $v['leave_endtime'];?></td>
							<td><?php echo $v['leave_duration'];?></td>
							<td><?php if($v['type']==1){echo "事假";}else{echo '病假';}?></td>
							<td class="text-l">
								<div class="progress-bar progress-bar-warning"><span class="sr-only radius" style="width:<?php echo $sr;?>%"></span></div>
							</td>
							<td class="text-c">
							<?php if ($v['leave_state']==0){?>
								<span class='label radius' id='<?php echo $v['leave_id'];?>'>待审核</span>
							<?php }else if($v['leave_state']==1){?>
								<span class='label label-success' id='<?php echo $v['leave_id'];?>'>通过</span>
							<?php }else{?>
								<span class='label label-warning radius' id='<?php echo $v['leave_id'];?>'>撤销</span>
							<?php }?>
							
							</td>
							<td class="td-manage">
								<a style="text-decoration:none" class="ml-5" onClick="leave_edit('请假单查看','leave_pre.php?id=<?php echo urlencode($v['leave_id']);?>','10001')" href="javascript:;" title="查看"><i class="Hui-iconfont">&#xe695;</i></a>
								<?php if ($v['leave_state']!=1){?> 
								<a style="text-decoration:none" class="ml-5" onClick="leave_del(this,<?php echo urlencode($v['leave_id']);?>,<?php echo $v['leave_state'];?>)" href="javascript:;" title="<?php if ($v['leave_state']==0){echo '是否撤销？';}else if($v['leave_state']==3){echo '是否重新提交？';}?>">
									<i class="Hui-iconfont"><?php if ($v['leave_state']==0){?>&#xe66b;<?php }else{?>&#xe66c;<?php }?></i></a>
								<?php }?>
							</td>
						</tr>
						<?php }?>
					</tbody>
				</table>
			</div>
		</article>
	</div>
</section>



<!--_footer 作为公共模版分离出去-->
<?php require_once 'comm/_footer.php';?>
<!--/_footer /作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">
$('.table-sort').dataTable({
	"aaSorting": [[ 1, "desc" ]],//默认第几个排序
	"bStateSave": true,//状态保存
	"aoColumnDefs": [
	  //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
	  {"orderable":false,"aTargets":[0,6]}// 制定列不参与排序
	]
});
/*-添加*/
function leave_add(title,url){
	var index = layer.open({
		type: 2,
		title: title,
		content: url,
		end: function () {
	            location.reload();
        	}
	});
	layer.full(index);
}
/*图片-编辑*/
function leave_edit(title,url,id){
	var index = layer.open({
		type: 2,
		title: title,
		content: url
	});
	layer.full(index);
}
/*图片-删除*/
function leave_del(obj,id,state){
	var x_msg = obj.title;
	
	layer.confirm(x_msg,function(index){
		$.ajax({
			url:'comm/leave_backout.php',
			data:{leave_id:id,leave_state:state},
			type:"POST",
			success:function(msg){
				if(msg==1){
					//更改为撤销
					$('#'+id).removeClass("radius").addClass(" label-warning radius");
					console.log($('.Hui-iconfont').eq(0).text());
					$('.Hui-iconfont').eq(0).text('&#xe66c;');   //代码有点小BUG
					obj.title = '是否重新提交';
					$('#'+id).text("撤销");
					layer.msg('已撤销！',{icon:1,time:1000});
				}else if(msg==3){
					//取消撤销
					$('#'+id).removeClass(" label-warning radius").addClass("radius");
					$('.Hui-iconfont').eq(0).text('&#xe66b;');
					obj.title = '是否撤销';
					$('#'+id).text("待审核");
					layer.msg('取消撤销！',{icon:1,time:1000});
				}else{
					layer.msg('操作失败！',{icon:2,time:1000});
				}
			},
			error:function(){
				layer.msg('操作错误！',{icon:3,time:1000});
			}
		});
	});
}
</script>
<!--/请在上方写此页面业务相关的脚本-->
<!--/请在上方写此页面业务相关的脚本-->

</body>
</html>